//
//  RunFriendCollectionViewCell.m
//  Run
//
//  Created by sxz on 16/4/6.
//  Copyright © 2016年 BetaTheta. All rights reserved.
//

#import "RunFriendCollectionViewCell.h"

@implementation RunFriendCollectionViewCell


- (void)setRunFriendModel:(RunFriendModel *)runFriendModel {
    _runFriendModel = runFriendModel;
    if (self) {
        
        _likeImage.image = [UIImage imageNamed:@"点赞"];
        
        _sayImage.image = [UIImage imageNamed:@"评论"];

        [_image sd_setImageWithURL:[NSURL URLWithString:runFriendModel.image]];
        [_avatar sd_setImageWithURL:[NSURL URLWithString:runFriendModel.avatar]];
        
        _text.text = runFriendModel.text;
        _like_count.text = runFriendModel.like_count;
        _comment_count.text = runFriendModel.comment_count;
        _username.text = runFriendModel.username;
        
    

        
    }
    
}


- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        self.layer.cornerRadius = 10;
        self.clipsToBounds = YES;
        
        self.image = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.avatar = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.text = [[UILabel alloc] initWithFrame:CGRectZero];
        self.like_count = [[UILabel alloc] initWithFrame:CGRectZero];
        self.comment_count = [[UILabel alloc] initWithFrame:CGRectZero];
        self.username = [[UILabel alloc] initWithFrame:CGRectZero];
        self.sayImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.likeImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.linLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        
        [self.contentView addSubview:_image];
        [self.contentView addSubview:_avatar];
        [self.contentView addSubview:_text];
        [self.contentView addSubview:_like_count];
        [self.contentView addSubview:_comment_count];
        [self.contentView addSubview:_username];
        [self.contentView addSubview:_linLabel];
        
        [self.contentView addSubview:_sayImage];
        
        [self.contentView addSubview:_likeImage];
        
        
        
    }
    return self;
}


- (void)layoutSubviews {
    _image.frame = CGRectMake(0, 0, CWIDTH, CHEIGHT/2);
//    _image.backgroundColor = [UIColor greenColor];
    
    _text.frame = CGRectMake(0, CHEIGHT/2, CWIDTH, 40);
    _text.textAlignment = NSTextAlignmentCenter;
    _text.numberOfLines = 2;
    _text.font = [UIFont systemFontOfSize:12];

    
    _likeImage.frame = CGRectMake(5, _text.frame.origin.y + 50, 20, 20);

    
    _like_count.frame = CGRectMake(_likeImage.frame.origin.x+20, _text.frame.origin.y + 50, 50, 25);
    _like_count.textAlignment = NSTextAlignmentCenter;
    _like_count.font = [UIFont systemFontOfSize:10];

    
    _sayImage.frame = CGRectMake(_like_count.frame.origin.x + 60, _text.frame.origin.y + 50, 20, 20);

    
    
    _comment_count.frame = CGRectMake(_sayImage.frame.origin.x + 20, _text.frame.origin.y + 50, 50, 25);
    _comment_count.font = [UIFont systemFontOfSize:10];
    _comment_count.textAlignment = NSTextAlignmentCenter;
//    _comment_count.backgroundColor = [UIColor cyanColor];
    
    
    _linLabel.frame = CGRectMake(0, _comment_count.frame.origin.y + 40, CWIDTH, 1);
    _linLabel.backgroundColor = [UIColor grayColor];
    
    _avatar.frame = CGRectMake(10, _linLabel.frame.origin.y + 10, 30, 30);
    _avatar.layer.cornerRadius = 15;
    _avatar.clipsToBounds = YES;
//    _avatar.backgroundColor = [UIColor magentaColor];
    
    _username.frame = CGRectMake(_avatar.frame.origin.x + 40, _linLabel.frame.origin.y + 10, 100, 30);
    _username.font = [UIFont systemFontOfSize:13];
    
//    _username.backgroundColor = [UIColor orangeColor];
    
}





@end
